package com.study.demo.dao;

import com.study.demo.dto.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

@Repository
public class MongoDao {

    @Autowired
    private MongoTemplate mongoTemplate;

    public void save(Student student) {
        mongoTemplate.save(student);
    }

    public void find(String name){
        Query query = new Query(Criteria.where("name").is(name));
        Object object = mongoTemplate.find(query, Student.class);
        System.out.println(object.toString());
    }
}
